package com.syj.collect.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.syj.collect.app.R;


public class MyLinearLayout extends LinearLayout {
    private View view;
    private TextView textView;
    private ImageView img_hrad;
    public MyLinearLayout(Context context) {
        super(context);
        init(context);
    }
    private void init(Context context) {
        view= LayoutInflater.from(context).inflate(R.layout.layout_llayout, this);
        textView=view.findViewById(R.id.num_tv);
        img_hrad=view.findViewById(R.id.img_hrad);
    }

    public MyLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }
    public MyLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void setText(int shoppingCartNum) {
        if (shoppingCartNum>0){
            textView.setVisibility(View.VISIBLE);
        }else {
            textView.setVisibility(View.GONE);
        }
        textView.setText(shoppingCartNum+"");
    }

    public void setImg(int pingjia) {
        img_hrad.setBackgroundResource(pingjia);
    }
}
